/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode ListNode;
struct ListNode* middleNode(struct ListNode* head)
{
    int count = 0;
    ListNode* pcur = head;
    while (pcur)
    {
        count++;
        pcur = pcur->next;
    }
    count = (count + 2) / 2;
    count--;
    pcur = head;
    while (count)
    {
        pcur = pcur->next;
        count--;
    }
    return pcur;
}